package com.adcc.swingui.demo.panel;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 * <p>
 * Title: AbsContentPanel
 * </p>
 * <p>
 * Description: 显示内容面板基类
 * </p>
 * <p>
 * Copyright: Copyright (c) 2010
 * </p>
 * 
 * @author jeff.zhao
 * @version 1.0.0
 */
public abstract class AbsContentPanel extends JPanel {
	private static final long serialVersionUID = 1L;
	private JPanel contentPanel;
	private JLabel titLab;

	// private JButton butapply ;

	protected AbsContentPanel() {
		this.init();
	}

	public void setShowtitle(String showtitle) {
		this.titLab.setText(showtitle);
	}

	private void init() {
		this.setLayout(new BorderLayout());
		JPanel titPanel = new JPanel();
		((FlowLayout) titPanel.getLayout()).setAlignment(FlowLayout.LEFT);
		((FlowLayout) titPanel.getLayout()).setHgap(5);
		((FlowLayout) titPanel.getLayout()).setVgap(10);
		titPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.GRAY));

		this.titLab = new JLabel();
		this.titLab.setFont(new Font("宋体", Font.BOLD, 13));
		titPanel.add(titLab);

		this.add(titPanel, BorderLayout.NORTH);

		JPanel spacePanel = new JPanel(new GridLayout(1, 1, 10, 10));
		this.contentPanel = new JPanel();
		spacePanel.add(contentPanel);

		this.add(spacePanel, BorderLayout.CENTER);

		FlowLayout botlay = new FlowLayout(FlowLayout.RIGHT);
		botlay.setHgap(5);
		JPanel botPanel = new JPanel(botlay);

		/*
		 * this.butapply = new JButton( "应  用") ;
		 * this.butapply.setPreferredSize( new Dimension( 80 , 25 ) ) ;
		 * this.butapply.addActionListener( new ActionListener() { public void
		 * actionPerformed(ActionEvent e) { apply() ; } }) ;
		 * 
		 * botPanel.add( this.butapply ) ;
		 */
		this.add(botPanel, BorderLayout.SOUTH);

	}

	public JPanel getContentPanel() {
		return contentPanel;
	}

	public void setContentPanel(JPanel contentPanel) {
		this.contentPanel = contentPanel;
	}

	public abstract boolean apply();

	public abstract void restoreDefault();
}
